#!/bin/bash
set -v

# Move to working directory
cd /home/xionghaonan/riscv-dataset/riscv_build_dataset

# Activate conda env
conda activate riscv-dataset

# Setup OBS_COOKIE env var
# export OBS_COOKIE=aWVUaTcydGVOTERnaTZVdk1LMzNMTkllbjhpekhDbDBPd3liS28xdTlWM3FXdVI4TGV4TVJvOGUyeEIyTHJzcURmQXB3RlRZT2JHZzVoeUxPVG9oRjNFRWk4V2d1RkNmeFdJaGZUWk5JSXk1T2E2OUlGalNVb1I0KzFSQzhzakpTaHQvWXg0aGhldjlIbHBxQ2RINEROd2twT0xndExucTcvMkFNK3hLMktRc0RCQUFCOUxDWmsxdjJFeHNDOW4wbDNDaFJYU3MwUEx2aEhUUkpUN3lhT3RGekcwSk9pUUxDckhJZGRZU2VKZz0tLUhGZzYrRzFDQmZMZzk2cGpWY1dOcHc9PQ%3D%3D--e766f63cdda0664f17f0ac8c32028823c58ffe7d
export OBS_COOKIE=MEEvalpUNGJoTUhxdGMwOWppT0t1bWxUZkwxV0pBbVlZbVpsdEdCVVM1UXo1MUV1TXFUaWYza2lKK1NnN2trZUdlVUxmVkVKWGUvRVNYdkVPZ3lBdW83TGdKZFYvVURYUmdXVDY3a2YzTmxrdGdHLzlnRCtmcTFrTTA2eEVoVTJ4bTluN2lRem1pT2ZlMFhEMG9OT2lScGgrWkluYkxaVW0wb1VFNXhjWTRFQXZOUnRuYTRSWlVsVEs1QW9BY3R2cUNFK1dVZHllVzNTS0JUeWFDTnR3NjJ2M0UrbEFnOW42L2RMaG1JcWoxMD0tLVNMcjFoMU8xbjZBT3FSQit6aG9USVE9PQ%3D%3D--2b2230430a4454be24c5cc3ec29a81691f5c8443
export OBS_ARCH=riscv64

#export OBS_PROJECT=openEuler:22.03
#export OBS_REPO=22.03

#export OBS_PROJECT=openEuler:22.09
#export OBS_REPO=openEuler_2209_self

#export OBS_PROJECT=openEuler:23.09:BaseOS:01
#export OBS_REPO=20230921

#export OBS_PROJECT=openEuler:23.09
#export OBS_REPO=23.09

#export OBS_PROJECT=openEuler:23.09:RISC-V
#export OBS_REPO=standard_riscv64

#export OBS_PROJECT=openEuler:Mainline:RISC-V
#export OBS_REPO=standard_riscv64

export OBS_PROJECT=openEuler:24.03
export OBS_REPO=mainline_riscv64

# Fetch and setup latest spider src and database
# git pull
# python manage.py makemigrations
# python manage.py migrate

# Get projects from OBS
time python obs/spider/projects_spider.py

# Get Packages from OBS
time python obs/spider/project_package_spider.py

# Get Revisions from OBS
time python obs/spider/package_revision_spider.py

# Get job histories from OBS
time python obs/spider/job_history_spider.py

# Get build logs form OBS
time python obs/spider/package_build_log_spider.py

# Sync latest source code
time python obs/spider/source_code_spider.py
